<%--
  Created by IntelliJ IDEA.
  User: set_free
  Date: 003
  Time: 8:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="utils.FileUtil,java.util.List"  pageEncoding="utf-8"%>
<%@ page import="java.io.File" %>

<html>
  <head>
    <title>测试</title>
    <script>
      function turnPage(url){
        if(url){
          window.location.href = url + "&rn=" + Math.random();
        }
      }
    </script>
  </head>
  <body>
  测试题
  <div>
    <p><a href="javascript:void(0);" onclick="turnPage('<%=request.getContextPath()%>/DownloadServlet?fileName=20200704JavaTest.docx');" target="_blank">20200704JavaTest.docx</a></p>
    <p><a href="javascript:void(0);" onclick="turnPage('<%=request.getContextPath()%>/DownloadServlet?fileName=20200711Java_Collection_test.docx');" target="_blank">20200711Java_Collection_test.docx</a></p>
    <p><a href="javascript:void(0);" onclick="turnPage('<%=request.getContextPath()%>/DownloadServlet?fileName=20200704Java_mysql_Test.docx');" target="_blank">20200704Java_mysql_Test.docx</a></p>
  </div>
  <hr/>
  文件列表（点击下载）：
  <div>
    <%
      String filePath = request.getServletContext().getRealPath("/doc_exames");
      List<File> fileList = FileUtil.getallfile(filePath);
      for (int i = 0; i < fileList.size(); i++) {
        String fileTempName = fileList.get(i).getName();
        %>
    <%=i %>.<a href="javascript:void(0);" onclick="turnPage('<%=request.getContextPath()%>/DownloadServlet?filePath=doc_exames&fileName='+fileTempName);" target="_blank"><%=fileTempName%></a>
    <br/>
    <%
      }
    %>
  </div>
  </body>
</html>
